package com.ithei.date.异常;

import java.util.ArrayList;
import java.util.Iterator;

public class 并发修改异常 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        list.add("ggg");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            if("ccc".equals(next)){
                list.remove("ccc");
            }
            list.remove(0);
            //list.add("qqq");
        }
        System.out.println(list);
    }
}
